<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>
<body class="no-skin">
<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="<?php echo site_url(X_URL.'menu/update');?>" method="post">
						<?php echo csrf_hidden();?>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10">
                                    上级菜单 </label>
                                <input name="id" value="<?php if(isset($currentmenu) && !empty($currentmenu)):?><?php echo $currentmenu['id'];?><?php endif; ?>" type="hidden">
                                <div class="col-sm-9">
                                    <select id="pid" name="pid" class="rcol-xs-10 col-sm-5">
                                        <option value="0" <?php if(isset($currentmenu) && !empty($currentmenu)):?><?php if($currentmenu['pid'] == 0){?>selected="selected"<?php }?><?php endif; ?>
                                        >顶级菜单</option>
										  <?php
                                            if(isset($option)) {
                                                foreach ($option as $key => $v) {
                                          ?>
                                                <option value="<?php echo $v['id'];?>" <?php if( isset($currentmenu) && $currentmenu['pid'] == $v['id']){?>selected="selected"<?php }?> ><?php echo $v['title'];?></option>
                                                <?php
                                                if(isset($v['children'])) {
                                                    foreach ($v['children'] as $key => $vv) {
                                                ?>
                                                    <option value="<?php echo $vv['id'];?>" <?php if(isset($currentmenu) && $currentmenu['pid'] == $vv['id']){?>selected="selected"<?php }?> >&nbsp;&nbsp;┗━<?php echo $vv['title'];?></option>
                                                <?php } ?>
                                                <?php } ?>
                                            <?php } ?>
                                            <?php } ?>
                                    </select>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 菜单名称 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="title" id="title" class="rcol-xs-10 col-sm-5"
                                           value="<?php if(isset($currentmenu) && !empty($currentmenu)):?><?php echo $currentmenu['title'];?><?php endif; ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group" id="name_group" style="display:none;">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 控制器/方法 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="name" id="name" placeholder="控制器名称，如：Index/index"
                                           class="col-xs-10 col-sm-5" value="<?php if(isset($currentmenu) && !empty($currentmenu)):?><?php echo $currentmenu['name'];?><?php endif; ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2">
                                    菜单图标 </label>
                                <div class="col-sm-1">
                                    <section class="btn btn-sm btn-info iconpicker" id="icon" name="icon" role="iconpicker">
                                        <i></i>
                                        <input type="hidden" value="<?php if(!empty($currentmenu['icon'])){ echo $currentmenu['icon'];}else{echo "";};?>">
                                        <span class="caret"></span>
                                    </section>

                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <script type="text/javascript">
                                var iconChoose = "<?php if(!empty($currentmenu['icon'])){ echo $currentmenu['icon'];}else{echo "";};?>";
                            </script>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 显示状态 </label>
                                <div class="control-label no-padding-left col-sm-1">
                                    <label>
                                        <input name="islink" id="islink"
                                        <?php if(!empty($currentmenu) && $currentmenu['islink'] == 1){ ?>checked="checked"<?php } ?>
                                        value="1" class="ace ace-switch ace-switch-2" type="checkbox" />
                                        <span class="lbl"></span>
                                    </label>
                                </div>
                                <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
										</span>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 排序 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="o" id="o" placeholder="" class="col-xs-10 col-sm-5"
                                           value="<?php if(isset($currentmenu) && !empty($currentmenu)):?><?php echo $currentmenu['o'];?><?php endif; ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">越小越靠前</span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 页面提示</label>
                                <div class="col-sm-9">
                                    <textarea name="tips" id="tips" placeholder="页面提示" class="col-xs-10 col-sm-5"
                                              rows="5"><?php if(isset($currentmenu) && !empty($currentmenu)):?><?php echo $currentmenu['tips'];?><?php endif; ?></textarea>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<?php echo admin_css_url('bootstrap-iconpicker.min');?>
<?php echo admin_js_url('bootstrap-iconpicker-iconset-all');?>
<?php echo admin_js_url('bootstrap-iconpicker');?>
<script>
    $("#pid").change(function () {
        var pid = $(this).val();
        if(pid > 0){
            $("#name_group").show();
        }else{
            $("#name_group").hide();
        }
    });
</script>
</body>
</html>
